clc; clear; close all

% 分岔参数设置
r1_list = linspace(-4, 4, 800);   % 横轴参数
N_trans = 300;                    % 丢弃暂态
N_plot = 100;                     % 绘制采样点数
x_init = 0.1;                     % 初值

b1 = -3;                          % 移位常数

% 预分配
x_all = [];
r1_all = [];

for idx = 1:length(r1_list)
    r1 = r1_list(idx);
    x = x_init;

    % 暂态
    for t = 1:N_trans
        x = CTBCS_next(x, r1, b1);
    end

    % 采集
    temp = zeros(1, N_plot);
    for t = 1:N_plot
        x = CTBCS_next(x, r1, b1);
        temp(t) = x;
    end
    x_all = [x_all, temp];
    r1_all = [r1_all, r1*ones(1, N_plot)];
end

% 绘图
figure
plot(r1_all, x_all, 'b.', 'MarkerSize', 1)
xlabel('r_1')
ylabel('x')
xlim([-4 4])
ylim([-1 1])
set(gca,'FontSize',13)
title('(c)', 'FontWeight', 'normal')

% === CTBCS核心映射函数 ===
function x_next = CTBCS_next(x, r1, b1)
    % F(x)：量子Logistic系统
    Fx = 4*x*(1-x);  
    % G(x)：3D-SIMM主变量简化（可改为你的SIMM函数）
    Gx = sin(2*pi*x) * sin(11.5/x);  
    x_next = cos(pi*(r1*Fx + (1-r1)*Gx) - b1);
end
